<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box {
        border: 25px solid gray;
        padding: 20px;
        background: yellow;
        background-clip: content-box;
        height: 400px;
        overflow: auto;
      }

      #box p {
        height: 100px;
      }
    </style>
  </head>
  <body>
    <div id="box">
      <p>hello box</p>
      <p>hello box</p>
      <p>hello box</p>
      <p>hello box</p>
    </div>
    <script>
      const box = document.getElementById("box");
      console.log(box.offsetWidth); // 外宽
      console.log(box.offsetHeight); // 外高
      console.log(box.clientLeft); // 左边框的宽度
      console.log(box.clientTop); //上边框的宽度
    </script>
  </body>
</html>
